package com.yjzx.util;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

/**
 * @author yjzx
 * @date 2024/4/20
 * @description
 */
public class ReflectionUtil {
    public static <T>List<T> reflectionGetParam(Object o,Class<T> clazz) throws IllegalAccessException {
        Field[] fields = o.getClass().getFields();
        List<T> list = new ArrayList<>();
        for (Field field : fields) {
            if (field.getType() == clazz) {
                list.add((T) field.get(o));
            }
        }
        return list;
    }
    public static <T>List<T> reflectionGetParam(Object o,TypeReflection<T> clazz) throws IllegalAccessException {
        Field[] fields = o.getClass().getFields();
        List<T> list = new ArrayList<>();
        for (Field field : fields) {
            if (field.getType() ==clazz.getClassT() ) {
                list.add((T) field.get(o));
            }
        }
        return list;
    }

    public static void main(String[] args) {

    }

}
